﻿using System;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;
using Bids.Core.Infrastructure;

namespace Bids.Core.DomainObjects
{
    [Serializable]
    public class SetMeal : IEntity
    {
        public int ID { get; set; }
        /// <summary>
        /// 套餐名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 费用
        /// </summary>
        public int Cost { get; set; }
        /// <summary>
        /// 预付款
        /// </summary>
        public int Imprest { get; set; }
        /// <summary>
        /// 设计师数量
        /// </summary>
        public string DesignerNum { get; set; }
        /// <summary>
        /// 稿件数量
        /// </summary>
        public string ManuscriptNum { get; set; }
        /// <summary>
        /// 无限修改
        /// </summary>
        public bool ModifyLimitless { get; set; }
        /// <summary>
        /// 任何源文件格式
        /// </summary>
        public bool AnySourceFormat { get; set; }
        /// <summary>
        /// 不满意退款
        /// </summary>
        public string Refund { get; set; }
        /// <summary>
        /// 是否拥有版权著作权
        /// </summary>
        public bool Copyright { get; set; }
        /// <summary>
        /// 是否100%原创
        /// </summary>
        public bool Original { get; set; }
        /// <summary>
        /// 是否100%满意
        /// </summary>
        public bool Satisfaction { get; set; }
        /// <summary>
        /// 风险成本
        /// </summary>
        public int RiskCost { get; set; }

        public IList<Task> Tasks { get; set; }

        public static MappingConfiguration<SetMeal> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<SetMeal>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.Name,
                t.Cost,
                t.Imprest,
                t.DesignerNum,
                t.ManuscriptNum,
                t.ModifyLimitless,
                t.AnySourceFormat,
                t.Refund,
                t.Copyright,
                t.Original,
                t.Satisfaction,
                t.RiskCost
            }).ToTable("SetMeals");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            threadMapping.HasAssociation(t => t.Tasks).WithOpposite(d => d.SetMeal).HasConstraint((t, d) => t.ID == d.SetMealId);
            return threadMapping;
        }
    }
}
